package utsc.apps.utschedule.util;

import com.actionbarsherlock.view.ActionMode;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;

public class GenericActionModeCallback implements ActionMode.Callback{

	private int _menuResID;
	private OnMenuItemClickedListener _onMenuItemClickedListener;
	//private MenuInflater _menuInflater;
	
	public GenericActionModeCallback( int menuResID, OnMenuItemClickedListener onMenuItemClickedListener){
		this._menuResID=menuResID;
		this._onMenuItemClickedListener=onMenuItemClickedListener;
		//this._menuInflater=menuInflater;
		
	}
	
	@Override
	public boolean onCreateActionMode(ActionMode mode, Menu menu) {
		/*if (_menuInflater!=null) {
			_menuInflater.inflate(_menuResID, menu);
		}*/
		mode.getMenuInflater().inflate(_menuResID, menu);
		return true;
	}

	@Override
	public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
		return false;
	}

	@Override
	public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
		if (_onMenuItemClickedListener!=null) {
			_onMenuItemClickedListener.onMenuItemClicked(item);
		}
		return true;
	}

	@Override
	public void onDestroyActionMode(ActionMode mode) {
	}
	
	public OnMenuItemClickedListener get_onMenuItemClickedListener() {
		return _onMenuItemClickedListener;
	}

	public void set_onMenuItemClickedListener(OnMenuItemClickedListener _onMenuItemClickedListener) {
		this._onMenuItemClickedListener = _onMenuItemClickedListener;
	}

	public int get_menuResID() {
		return _menuResID;
	}

	public void set_menuResID(int _menuResID) {
		this._menuResID = _menuResID;
	}

	/*public MenuInflater get_menuInflater() {
		return _menuInflater;
	}

	public void set_menuInflater(MenuInflater _menuInflater) {
		this._menuInflater = _menuInflater;
	}*/

	public static interface OnMenuItemClickedListener{
		public void onMenuItemClicked(MenuItem item); 
	}

}
